package com.hqyj.erp.email.web.scheduletask;

import com.hqyj.erp.email.util.MailUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
 * @Classname ScheduleTask
 * @Description 定时任务管理
 * @Date 2021-12-12 16:28
 * @Created by 508
 */
@Component
class scheduletask {
    @Autowired
    private MailUtils mailUtils;
    @Value("${spring.mail.username}")
    private String mailto;

    /**
     * 定时邮件发送任务，
     */
    @Scheduled(cron = "0 */5 * * * ?")
//    @Scheduled(cron = "0 */3 * * * ? ")
    /*public void task(){
        System.out.println("成功");
    }*/
    public void sendEmail(){
        //  定制邮件内容
        System.out.println("开始发送");
        StringBuffer content = new StringBuffer();
        content.append("欢迎访问："+508+"宿舍").append("\n");
        mailUtils.sendSimpleEmail(mailto,"欢迎访问",content.toString());
        System.out.println("发送成功！");
    }
}
